<template>
  <header>
    <div class="l-content">
      <el-button
        plain
        icon="el-icon-menu"
        size="mini"
        @click="changeCollapse"
      ></el-button>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item
          v-for="item in tabList"
          :key="item.path"
          :to="{ path: item.path }"
          >{{ item.label }}</el-breadcrumb-item
        >
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown @command="handleCommand" trigger="click" size="mini">
        <span>
          <img class="user" :src="userImg" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="a">个人中心</el-dropdown-item>
          <el-dropdown-item command="b" @click.native="loginOut"
            >退出</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      userImg: require("../assets/images/user.webp"),
    };
  },
  computed: {
    ...mapState("tab", ["isCollapse", "tabList"]),
  },
  methods: {
    ...mapMutations("tab", ["collapseMenu", "clearMenu"]),
    ...mapMutations("user", ["clearToken"]),
    handleCommand() {},
    changeCollapse() {
      this.collapseMenu();
    },
    loginOut() {
      this.clearToken();
      this.clearMenu();
      this.$router.push({ name: "login" });
    },
  },
};
</script>

<style lang="less" scoped>
header {
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .l-content {
    display: flex;
    align-items: center;
    .el-breadcrumb {
      margin-left: 20px;
    }
  }
  .r-content {
    .user {
      width: 45px;
      height: 45px;
      border-radius: 50%;
    }
  }
}
</style>
